﻿<UserControl x:Class="Visuals.Graph.WordsGraphControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:zoom="clr-namespace:WPFExtensions.Controls;assembly=WPFExtensions"
             xmlns:Graph="clr-namespace:Visuals.Graph"
             xmlns:Controls="clr-namespace:GraphSharp.Controls;assembly=GraphSharp.Controls"
             xmlns:Framework="clr-namespace:LSA.Framework;assembly=LSA.Framework">
    <zoom:ZoomControl Grid.Row="1" Zoom="0.2" ZoomBoxOpacity="0.5" Background="White">
        <zoom:ZoomControl.Resources>
            <DataTemplate x:Key="demoTemplate" DataType="{x:Type Framework:WordInfo}">
                <StackPanel Orientation="Horizontal" Margin="5">
                    <TextBlock x:Name="labelX" Text="{Binding Path=Word, Mode=OneWay}" Foreground="White" />

                    <StackPanel.ContextMenu>
                        <ContextMenu >
                            <MenuItem Header="Виж в свързаните документи" Icon="../Images/Green.png" Click="OpenSearchWindow" />
                            <MenuItem Header="Премахни от графиката" Icon="../Images/Orange.png" Click="RemoveWordFromGraph" />
                        </ContextMenu>
                    </StackPanel.ContextMenu>
                </StackPanel>
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding IsEntity}" Value="false">
                        <Setter TargetName="labelX" Property="Foreground" Value="Black" />
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>

            <Style TargetType="{x:Type Controls:VertexControl}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type Controls:VertexControl}">
                            <Border BorderBrush="White" Background="Black" x:Name="borderX" BorderThickness="2" CornerRadius="10,10,10,10" Padding="{TemplateBinding Padding}">
                                <ContentPresenter Content="{TemplateBinding Vertex}" ContentTemplate="{StaticResource demoTemplate}"/>

                                <Border.Effect>
                                    <DropShadowEffect BlurRadius="2" Color="LightGray" Opacity="0.3" Direction="315"/>
                                </Border.Effect>
                                
                                
                            </Border>
                            <ControlTemplate.Triggers>
                                <DataTrigger Binding="{Binding IsEntity}" Value="false">
                                    <Setter TargetName="borderX" Property="BorderBrush" Value="Black" />
                                    <Setter TargetName="borderX" Property="Background" Value="White" />
                                </DataTrigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <Style TargetType="{x:Type Controls:EdgeControl}">
                <Style.Resources>
                    <ToolTip x:Key="ToolTipContent">
                        <StackPanel>
                            <TextBlock Text="Връзка"/>
                            <TextBlock Text="{Binding Relation}" FontWeight="Bold"/>
                        </StackPanel>
                    </ToolTip>
                </Style.Resources>
                <Setter Property="ToolTip" Value="{StaticResource ToolTipContent}"/>
            </Style>
        </zoom:ZoomControl.Resources>
        <Graph:WordsGraphLayout x:Name="graphLayout" Margin="10" Graph="{Binding Path=Graph}"
        LayoutAlgorithmType="{Binding Path=LayoutAlgorithmType, Mode=OneWay}" OverlapRemovalAlgorithmType="FSA" HighlightAlgorithmType="Simple" />
    </zoom:ZoomControl>

</UserControl>
